package com.bwie.controller;

import com.bwie.pojo.TbBrand;
import com.bwie.pojo.TbProd;
import com.bwie.service.TbProdService;
import com.bwie.utils.Result;
import com.bwie.vo.AttaVo;
import com.bwie.vo.PageInfoVo;
import com.bwie.vo.ProdPageVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/shop/prod")
public class TbProdController {

    @Autowired
    TbProdService tbProdService;

    /**
     * @description 商品列表分页
     * @params [prodPageVo]
     * @return com.bwie.utils.Result
     * @author 杰
     * @date 2025/5/27 9:05
     */
    @PostMapping("/getProdList")
    public Result getProdList(@RequestBody ProdPageVo prodPageVo){

        return tbProdService.getProdList(prodPageVo);
    }


    /**
     * @description 添加商品
     * @params []
     * @return com.bwie.utils.Result
     * @author 杰
     * @date 2025/5/27 10:19
     */
    @PostMapping("/addProd")
    public Result addProd(@RequestBody @Validated TbProd tbProd){

        return tbProdService.addProd(tbProd);
    }


    /**
     * @description 商品单位下拉框
     * @params []
     * @return com.bwie.utils.Result
     * @author 杰
     * @date 2025/5/27 11:24
     */
    @PostMapping("/getUnitList")
    public Result getUnitList(){

        return tbProdService.getUnitList();
    }


    @PostMapping("/deleteAll")
    public Result deleteAll(@RequestBody List<TbProd> tbProds){

        return tbProdService.deleteAll(tbProds);
    }


    @PostMapping("/addProdAtta")
    public Result addProdAtta(@RequestBody AttaVo attaVo){
        return tbProdService.addProdAtta(attaVo);
    }




}
